package com.ratp.expertisetechnique;

import com.ratp.bean.Expertise;
import com.ratp.bean.UtilsBean;
import com.ratp.composants.CustomTextWatcher;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;

public class SignalementNEngageantPasElec extends Activity {
	private TextView editCircuitElecPas;
	private TextView editSignalExtElecPas;
	private TextView editDiversElecPas;
	private TextView editRampeElecPas;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.signalement_negageant_pas_elec);
		
		initVariables();
		
		initEcouteurs();
	}

	private void initVariables() {
		editCircuitElecPas = (EditText) findViewById(R.id.editCircuitElecPas);
		editSignalExtElecPas = (EditText) findViewById(R.id.editSignalExtElecPas);
		editDiversElecPas = (EditText) findViewById(R.id.editDiversElecPas);
		editRampeElecPas = (EditText) findViewById(R.id.editRampeElecPas);
		
		Expertise expertise = UtilsBean.getExpertiseInstance();

		editCircuitElecPas.setText(expertise.getCircuitElecMoteurNengagePas());
		editSignalExtElecPas.setText(expertise.getSignalisationExtNengagePas());
		editDiversElecPas.setText(expertise.getDiversElectNengagePas());
		editRampeElecPas.setText(expertise.getRmapePMRNengagePas());
	}

	private void initEcouteurs() {



		editCircuitElecPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setCircuitElecMoteurNengagePas(s.toString());
			}
		});
		editSignalExtElecPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setSignalisationExtNengagePas(s.toString());
			}
		});
		editDiversElecPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setDiversElectNengagePas(s.toString());
			}
		});
		editRampeElecPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setRmapePMRNengagePas(s.toString());
			}
		});
	}
}
